package com.jp.knowledge.command;

import android.content.Context;
import android.os.Bundle;
import android.support.annotation.NonNull;

import java.io.Serializable;

/**
 * Created by 528787067@qq.com on 2017/6/17.
 *
 * 命令接收者，用于封装命令
 */

public class CommandReceiver {

	private Context context;
	private String commpanyId;
	private String recordId;
	private String messageId;
	private String parameterId;
	private Bundle extra;

	public CommandReceiver(@NonNull Context context){
		this(context, null, null, null, null, null);
	}

	public CommandReceiver(@NonNull Context context, String companyId, String recordId, String messageId, String parameterId, Bundle extra){
		this.context = context;
		setCompanyParams(companyId, recordId, messageId, parameterId, extra);
	}

	public Context getContext() {
		return context;
	}

	public String getCommpanyId() {
		return commpanyId;
	}

	public void setCommpanyId(String commpanyId) {
		this.commpanyId = commpanyId;
	}

	public String getRecordId() {
		return recordId;
	}

	public void setRecordId(String recordId) {
		this.recordId = recordId;
	}

	public String getMessageId() {
		return messageId;
	}

	public void setMessageId(String messageId) {
		this.messageId = messageId;
	}

	public String getParameterId() {
		return parameterId;
	}

	public void setParameterId(String parameterId) {
		this.parameterId = parameterId;
	}

	public Bundle getExtra() {
		return extra;
	}

	public void setExtra(Bundle extra) {
		this.extra = extra;
	}

	public void setCompanyParams(String companyId, String recordId, String messageId, String parameterId, Bundle extra){
		this.commpanyId = companyId;
		this.recordId = recordId;
		this.messageId = messageId;
		this.parameterId = parameterId;
		this.extra = extra;
	}

	public static class Builder{

		private CommandReceiver receiver;

		public Builder(@NonNull Context context){
			receiver = new CommandReceiver(context);
		}

		public Builder withCompanyId(String companyId){
			receiver.setCommpanyId(companyId);
			return this;
		}

		public Builder withRecordId(String recordId){
			receiver.setRecordId(recordId);
			return this;
		}

		public Builder withMessageId(String messageId){
			receiver.setMessageId(messageId);
			return this;
		}

		public Builder withParameterId(String parameterId){
			receiver.setParameterId(parameterId);
			return this;
		}

		public Builder withExtra(Bundle extra){
			receiver.setExtra(extra);
			return this;
		}

		public CommandReceiver build(){
			return receiver;
		}
	}
}
